package com.tansun.easycare.rule.executionblock.entity;

public class BPMNShape {
    
    private String id;
	private int width=110;
    private int height=48;
    private int x;
    private int y;
    
    public BPMNShape() {
		super();
	}

    
	public BPMNShape(String id, int x, int y) {
		super();
		this.id = id;
		this.x = x;
		this.y = y;
	}


	public BPMNShape(String id, int width, int height, int x, int y) {
		super();
		this.id = id;
		this.width = width;
		this.height = height;
		this.x = x;
		this.y = y;
	}

	public String toString(String space) {
    	StringBuffer sb = new StringBuffer();
    	if(space==null)space="";
    	sb.append(space + "<bpmndi:BPMNShape bpmnElement=\"" + id + "\">\n");
        sb.append(space + "	<dc:Bounds x=\"" + x + "\" y=\"" + y + "\" width=\"" + width + "\" height=\"" + height + "\"/>\n");
        sb.append(space + "</bpmndi:BPMNShape>\n");
		return sb.toString();
    }

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.height = height;
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}
	
	public BPMNEdge connnectTo(BPMNShape o) {
		int x1 = this.x + this.width / 2 ;
		int y1 = this.y + this.height / 2;
		int x2 = o.getX() + o.getWidth() / 2;
		int y2 = o.getY() + o.getHeight() / 2;
		String rectid = this.id+"-"+o.getId();
		BPMNEdge bpmnEdge = new BPMNEdge(x1, y1, x2, y2, rectid);
		return bpmnEdge;
	}
    
}
